//
//  AppDelegate.m
//  iOSProject
//
//  Created by Charles on 2020/2/22.
//  Copyright © 2020 Charles. All rights reserved.
//

#import "AppDelegate.h"
#import "PlatformRouterImp.h"
#import "ViewController.h"
#import <Flutter/Flutter.h>

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    if (@available(iOS 13,*)) {
        return YES;
    }else{
        PlatformRouterImp *router = PlatformRouterImp.new;
        [FlutterBoostPlugin.sharedInstance startFlutterWithPlatform:router onStart:^(FlutterEngine * _Nonnull engine) {
            
        }];
        
        self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
        [self.window makeKeyAndVisible];

        ViewController *nativeView = [[ViewController alloc]init];
        nativeView.title = @"首页";
        
        FLBFlutterViewContainer *flutterView = FLBFlutterViewContainer.new;
        [flutterView setName:@"tab" params:@{}];
        flutterView.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"flutter_tab" image:nil tag:1];
        
        UITabBarController *tabVC = [[UITabBarController alloc] init];
        tabVC.viewControllers = @[nativeView,flutterView];
        
        UINavigationController *navCtrl = [[UINavigationController alloc]initWithRootViewController:tabVC];
        router.navigationController = navCtrl;
        
        self.window.rootViewController = navCtrl;
        return YES;
    }
}


#pragma mark - UISceneSession lifecycle


- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
    // Called when a new scene session is being created.
    // Use this method to select a configuration to create the new scene with.
    return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
}


- (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet<UISceneSession *> *)sceneSessions {
    // Called when the user discards a scene session.
    // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
    // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}


@end
